home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pbaseiv.zip / P4UTL005.TIP < prev    next >
Text File  |  1991-12-16  |  3KB  |  83 lines

  1. I'm a Windows fan, but I miss having a DOS prompt
  2. immediately available. When I need to type an ASCII file or
  3. list a directory, I use a Turbo Pascal program, ONESHOT.PAS
  4. [see listing]. The program works like Program Manager's and
  5. File Manager's RUN options but is easier to use and
  6. recognizes built-in DOS commands like DIR and COPY.
  7.  
  8. [A compiled, ready-to-run version of this program,
  9. ONESHOT.EXE, is included in the P4UTIL directory on your
  10. PowerBase *.* Volume IV diskette. If you want to modify the
  11. program, copy the listing below to a .PAS file by pressing
  12. the Alt-F key.]
  13.  
  14. C. D. Pirkey
  15. St. Louis, Missouri
  16.  
  17. Editor's note: Although you can open a DOS Prompt window to
  18. issue DOS commands, that window will stay open until you
  19. close it. ONESHOT is ideal for any once-and-done DOS
  20. command.
  21.  
  22. I added several extensions to Mr. Pirkey's original
  23. submission. Like COMMAND.COM and the PROMPT $P$G command,
  24. ONESHOT displays the current directory within the command
  25. prompt. A double greater-than symbol (>>) reminds you that
  26. this is not the usual DOS prompt. After you type a response,
  27. ONESHOT executes built-in DOS commands directly. For other
  28. commands, ONESHOT searches the current PATH for a COM file,
  29. an EXE file, or a BAT file, in that order. You can override
  30. this search order by including the file name's
  31. extension--MYPROG.EXE, for example.
  32.  
  33. After compiling ONESHOT with Turbo Pascal 5.5 or 6.0, open
  34. File Manager, locate ONESHOT.EXE, and drag it to a Program
  35. Manager group window. To use ONESHOT, select its icon and
  36. type any DOS command or program name at the resulting
  37. prompt. After the command finishes, ONESHOT reports the
  38. current DOS error- and exit-code values, or `0' if no
  39. problems were detected. Press <Enter> to return to Windows.
  40.  
  41. If ONESHOT's window stays visible, press <Alt>-<F4> to close
  42. it, start the Windows PIF Editor, open _DEFAULT.PIF, and
  43. then check the box labeled `Close Window on Exit'. After you
  44. have made this change, ONESHOT's window will disappear
  45. automatically.
  46.  
  47. Postscript: The original program published with this tip was
  48. considerably longer than the one included here, and had
  49. several bugs. (For instance, it converted your command to
  50. all uppercase -- which might cause it to fail -- and claimed
  51. to return the DOS error level for a program when in fact it
  52. did not. Also, it missed some internal commands that are now
  53. part of some versions of DOS.) This one is much smaller and
  54. simpler, and no longer tries to report the DOS error and
  55. exit codes, but it does what it says it does correctly.
  56.  
  57.  
  58. ONESHOT.PAS
  59.  
  60. ---- BEGIN LISTING ----
  61. {$M $2000,0,0 }
  62. program OneShot;
  63. uses dos;
  64. var
  65.   command : string;
  66. begin
  67.   getdir(0, command);
  68.   write(command, '>>');
  69.   readln(command);
  70.   swapvectors;
  71.   exec(getenv('COMSPEC'), '/C ' + command);
  72.   swapvectors;
  73.   write(#13#10'Press <Enter> to return to Windows. ');
  74.   readln
  75. end.
  76. ---- END LISTING ----
  77.  
  78. Title: One-Shot DOS Prompt for Windows
  79. Category: MISC
  80. Issue date: Apr 1991
  81. Editor: Tom Swan
  82. Supplementary files: P4UTIL\ONESHOT.EXE
  83.